<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>商品同步</title>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/dataapi/css/css.css" />
    <script type="text/javascript" src="__PUBLIC__/dataapi/js/jquery.min.js"></script>
    <!-- <script type="text/javascript" src="__PUBLIC__/dataapi/js/page.js" ></script> -->
</head>
<script>
    //全选
    function doallcheck(){
        var allche = document.getElementById("allid");
        var che = document.getElementsByName("mycheckbox");
        if(allche.checked == true){
            for(var i=0;i<che.length;i++){
                che[i].checked="checked";
            }
        }else{
            for(var i=0;i<che.length;i++){
                che[i].checked=false;
            }
        }
    }
    function doclickcheck(obj) {
        if(obj.checked==false){
            var allche = document.getElementById("allid");
            allche.checked = false;
        }
    }
    var page = <?php echo isset( $_GET['p'] ) && $_GET['p'] ? $_GET['p'] : 1; ?>;
    function fun(){
        obj = document.getElementsByName("mycheckbox");
        check_val = [];
        for(k in obj){
            if(obj[k].checked)
                check_val.push(obj[k].value);
        }
//        alert(check_val);
        $.ajax({
            type:'post',
            url:'__URL__/syncGood',
            dataType:'json',
            data:{
                "ids":check_val
            },
            success: function(data){
                console.log(data);
                if (data.code == 200){
                    alert(data.msg);
                    window.location.href="synclist/p/"+page;
                }
            }

        });
    }

</script>

<body>
<div id="pageAll">
    <div class="pageTop">
        <div class="page">
            <img src="__PUBLIC__/dataapi/img/coin02.png" /><span><a href="#">首页</a>&nbsp;-&nbsp;<a
                href="#">同步管理</a>&nbsp;-</span>&nbsp;商品同步
        </div>
    </div>
    <div class="page">
        <hr/>
        <div class="banShow">
            <table border="1" cellspacing="0" cellpadding="0">
                <tr>
                    <td><input type="checkbox" id="allid" onclick="doallcheck()"/></td>
                    <td width="66px" class="tdColor tdC">序号</td>
                    <td width="200px" class="tdColor">en13码</td>
                    <td width="308px" class="tdColor">名称</td>
                    <td width="300px" class="tdColor">关键字</td>
                    <td width="100px" class="tdColor">重量</td>
                    <td width="150px" class="tdColor">单位</td>
                    <td width="215px" class="tdColor">市场价</td>
                    <td width="180px" class="tdColor">代发价格</td>
                    <td width="100px" class="tdColor">批发价</td>
                    <td width="100px" class="tdColor">锁货价</td>
                    <td width="220px" class="tdColor">最低批发数量</td>
                    <td width="220px" class="tdColor">最低锁货数量</td>
                    <td width="215px" class="tdColor">建议零售价</td>
                    <td width="180px" class="tdColor">库存</td>
                    <!--<td width="125px" class="tdColor">操作</td>-->
                </tr>
                <foreach name="list" item="goods">
                    <tr>
                        <td><input type="checkbox" name="mycheckbox" onclick="doclickcheck(this)" value="{$goods.id}"></td>
                        <!--<td><input type="checkbox" name="mycheckbox" onclick="doclickcheck(this)" checked="checked" value="{$goods.id}"></td>-->
                        <td>{$goods.id}</td>
                        <td>{$goods.earn13}</td>
                        <td>{$goods.name}</td>
                        <td>{$goods.info_keywords}</td>
                        <td>{$goods.weight}</td>
                        <td>{$goods.pom}</td>
                        <td>{$goods.market_price}</td>
                        <td>{$goods.acting_price}</td>
                        <td>{$goods.wholesale_price}</td>
                        <td>{$goods.lock_price}</td>
                        <td>{$goods.wholesale_start_num}</td>
                        <td>{$goods.lock_start_num}</td>
                        <td>{$goods.price}</td>
                        <td>{$goods.stock_num}</td>
                    </tr>
                </foreach>
                <tr>
                    <td align="right">
                        <input id="sync" type="submit" onclick="fun()" value="选中同步"/>
                        </td>
                </tr>
            </table>
            <tr class="content">
                <!--<td colspan="3" bgcolor="#FFFFFF">&nbsp;{$page}</td>-->
                <td colspan="3" bgcolor="#FFFFFF"><div class="pages">
                    {$page}
                </div></td>
            </tr>
        </div>
        <!-- banner 表格 显示 end-->
    </div>
    <!-- banner页面样式end -->
</div>

</div>


<!-- 删除弹出框 -->
<div class="banDel">
    <div class="delete">
        <div class="close">
            <a><img src="__PUBLIC__/dataapi/img/shanchu.png" /></a>
        </div>
        <p class="delP1">你确定要删除此条记录吗？</p>
        <p class="delP2">
            <a href="#" class="ok yes" onclick="del()">确定</a><a class="ok no">取消</a>
        </p>
    </div>
</div>
<!-- 删除弹出框  end-->
</body>

<script type="text/javascript">
    // 广告弹出框
    $(".delban").click(function(){
        $(".banDel").show();
    });
    $(".close").click(function(){
        $(".banDel").hide();
    });
    $(".no").click(function(){
        $(".banDel").hide();
    });
    // 广告弹出框 end

    function del(){
        var input=document.getElementsByName("check[]");
        for(var i=input.length-1; i>=0;i--){
            if(input[i].checked==true){
                //获取td节点
                var td=input[i].parentNode;
                //获取tr节点
                var tr=td.parentNode;
                //获取table
                var table=tr.parentNode;
                //移除子节点
                table.removeChild(tr);
            }
        }
    }
</script>
</html>